package com.liu.SocketTcp;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 服务端
 * 字符流
 */
public class SocketTcp03 {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8888);
        Socket socket = serverSocket.accept();
        BufferedReader bufferedReader = new BufferedReader((new InputStreamReader(socket.getInputStream())));
        String s = bufferedReader.readLine();
        System.out.println(s);

        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        bufferedWriter.write("hello cline");
        bufferedWriter.newLine();
        bufferedWriter.flush();


        serverSocket.close();
        socket.close();
        bufferedReader.close();
        bufferedWriter.close();
    }
}
